#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,del##i##verme=int(n);i<del##i##verme;++i)
#define rep1(i,n) for(int i=1,parano##i##a=int(n);i<=parano##i##a;++i)
#define per(i,n) for(int i=int(n)-1;i>=0;--i)
#define per1(i,n) for(int i=int(n);i>=1;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define y0 Lingluo
#define y1 VividCycle
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
const ll mod1=998244353;
const ll mod2=1000000007;
const ldb pi=3.14159265358979323846264338327950;
unsigned time_related_rand()
{
    return unsigned(chrono::steady_clock::now().time_since_epoch().count());
}
int t,n,m,l,vmax;
int d[100005],v[100005],a[100005];
int p[100005];int st[1000005];
vector<pair<int,int> > P;
int query(int x,int y)
{
    if(x==0) return st[y];
    return st[y]-st[x-1];
}
bool cmp(const pair<int,int>&QAQ,const pair<int,int>&R)
{
    return QAQ.se<R.se;
}
void Q()
{
    cin>>n>>m>>l>>vmax;P.clear();
    memset(st,0,sizeof(st[0])*(l+3));
    rep1(i,n)
    {
        cin>>d[i]>>v[i]>>a[i];
    }
    rep1(i,m)
    {
        cin>>p[i];++st[p[i]];
    }
    rep1(i,l) st[i]+=st[i-1];
    rep1(i,n)
    {
        if(v[i]<=vmax)
        {
            if(a[i]>0)
            {
                int dst=d[i]+(vmax*vmax-v[i]*v[i])/(2*a[i])+1;
                if(dst<=l&&query(dst,l))
                {
                    P.pb(mp(dst,l));
                }
            }
        }
        else
        {
            if(a[i]>=0)
            {
                if(query(d[i],l))
                {
                    P.pb(mp(d[i],l));
                }
            }
            else
            {
                int dst=d[i]+(v[i]*v[i]-vmax*vmax-1)/(2*(-a[i]));
                dst=min(dst,l);
                if(query(d[i],dst))
                {
                    P.pb(mp(d[i],dst));
                }
            }
        }
    }
    cout<<P.size()<<" ";
    int answer=0,cur=-1;
    sort(P.begin(),P.end(),cmp);
    for(pair<int,int> QAQ:P)
    {
        if(QAQ.fi>cur)
        {
            int y=*(upper_bound(p+1,p+m+1,QAQ.se)-1);
            ++answer;
            cur=y;
        }
    }
    cout<<m-answer<<"\n";
}
int main()
{
    #ifndef DEBUG
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>t;while(t--)Q();return 0;
    return 0;
}
/*
1. check file name, corner case, i or j, < or <=, x or y, p or q, > or >=, c or d, n or m, n or q, overflow
2. time / memory: by ulimit -v LIMIT(kb) and ulimit -s 1048576 (use time ./prog , size prog or usr/bin/time -v prog)
*/
/*
maybe sonner or later, I can fall in love with a leaf
*/